<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header" /}
<br/>
<table class="table table-bordered" style="width: 1300px;margin: 0 auto">
    <tr>
        <th>编号</th>
        <th>店铺id</th>
        <th>产品id</th>
        <th>产品名</th>
        <th>单价(元)</th>
        <th>购买数量(个)</th>
        <th>订单号</th>
        <th>下单时间</th>
        <th>合计(元)</th>
        <th>操作</th>
    </tr>
    {foreach $result as $val}
    <tr id="del{$val.id}" style="text-align: center">
        <td>{$val.id}</td>
        <td>{$val.sid}</td>
        <td>{$val.pid}</td>
        <td>{$val.pname}</td>
        <td>{$val.retailprice}</td>
        <td>{$val.number}</td>
        <td>{$val.ordernumber}</td>
        <td>{$val.date}</td>
        <td>{$val.total}</td>
        <td>
            <button onclick="del({$val.id})" type="button" class="btn btn-danger btn-xs"> 删除</button>
        </td>
    </tr>
    {/foreach}
</table>
<div style="margin-left: 30px">{$result->render()}</div>
</body>
<script>
    function del(id) {
        layer.confirm('你确定要删除啊',{bnt:['确定','取消']},
            function () {
                $.ajax({
                    url:"{:url('index/orders/delete')}",
                    data:'id='+id,
                    type:'post',
                    dataType:'json',
                    success:function (res) {
                        if(res.success){
                            layer.alert('删除成功',{bnt:['确定']},
                                function () {
                                    $("#del"+id+"").remove();
                                    window.location.reload();
                                }
                            );
                        }
                        if(res.error){
                            layer.alert(res.error);
                        }
                    }
                });
            }
        )
    }
</script>
</html>